import com.codezen.helper.Settings;
import com.codezen.helper.Worker;
import com.codezen.kinobaza.KinobazaTV;
import com.codezen.vkontakte.ajax.VkVideo;

import mx.utils.ObjectUtil;
import air.update.ApplicationUpdaterUI;
import air.update.events.UpdateEvent;

// includes
include 'DataProviders.as';
include 'Options.as';
include 'Kinobaza.as';
include 'Series.as';
include 'News.as';
include 'Search.as';
include 'PopupMenus.as';

// vars
private var vkVideoSearch:VkVideo;
private var kb:KinobazaTV;
private var sets:Settings;

[Bindable]
private var showSetts:Boolean;

private function initApp():void{
	setApplicationVersion();
	
	// check update
	var up:ApplicationUpdaterUI = new ApplicationUpdaterUI();
	up.updateURL = "http://vkopenmp.googlecode.com/hg/update.xml";
	up.isCheckForUpdateVisible = false;
	up.addEventListener(UpdateEvent.INITIALIZED, function():void{
		up.checkNow();
	});
	up.initialize();
	
	// init kinobaza
	kb = new KinobazaTV();
	
	// load settings
	sets = new Settings("config.xml");
	loadSettings();
	
	// load news
	loadNewMovies();
}

private function exitApp():void{
	this.exit();
}

private function dragApp(event:MouseEvent):void{
	nativeWindow.startMove();
}

private function setBusyState():void{
	cursorManager.setBusyCursor();
	loader_bg.visible = true;
	loader_wnd.currentState = 'Visible';
}

private function removeBusyState():void{
	cursorManager.removeBusyCursor();
	loader_wnd.currentState = 'Hidden';
	loader_bg.visible = false;
}

private function returnView():void{
	currentState='Series';
	nativeWindow.width = 800;
	nativeWindow.height = 600;
}

private function  setApplicationVersion():void {
	var appXML:XML = NativeApplication.nativeApplication.applicationDescriptor;
	var ns:Namespace = appXML.namespace();
	appDescription += "\nВерсия: "+appXML.ns::version;
}
